package edu.caltech.cs.techerlink;


import com.google.appengine.api.datastore.Key;

import java.util.List;
import java.util.Dictionary;

import java.util.Date;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable
public class Course {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;

	@Persistent
	private String department;
	
	@Persistent
	private int number;
	
	@Persistent
	private List<Student> students;
	
//	@Persistent
//	private List<Student> TAs;

	@Persistent
	private Dictionary<String, Date> dueDates;

	@Persistent
	private Dictionary<Student, Date> officeHours;

	private String calendarUrl;
	
	public Course(String department, int number) {
		this.department = department;
		this.number = number;
	}

	public Key getKey() {
		return key;
	}

	public String getDepartment() {
		return department;
	}
	
	public int getNumber() {
		return number;
	}
	
	public List<Student> getStudents() {
		return students;
	}
	
//	public List<Student> getTAs() {
//		return TAs;
//	}

	public Dictionary<String, Date> getDueDates() {
		return dueDates;
	}

	public Dictionary<Student, Date> getofficeHours() {
		return officeHours;
	}

    // Add student to course
    public void addStudent(Student student) {
    	students.add(student);
    }           

    // Remove student from course
    public void delStudent(Student student) {
    	students.remove(student);
    }           

    // Add TA to course
//    public void addTA(Student TA) {
//    	TAs.add(TA);
//    }        

    // Remove TA from course
//    public void delTA(Student TA) {
//    	TAs.remove(TA);
//    }          

    // Add office hour
    public void addOH(Student student, Date date) {
    	officeHours.put(student, date);
    }

    // Remove office hour
    public void delOH(Student student) {
    	officeHours.remove(student);
    }

    // Add assignment
    public void addAsg(String asg, Date duedate) {
    	dueDates.put(asg, duedate);
    }

    // Remove assignment
    public void delAsg(String asg) {
    	dueDates.remove(asg);
    }
    
    public void setUrl(String url) {
    	calendarUrl = url;
    }
    
    public String getUrl(String url) {
    	return calendarUrl;
    }
}